package com.lw.json.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

/**
 * @Description: json语法
 * @ClassName: JsonGrammar
 * @Author: lanwei
 * @Date: 2022/12/13 14:52
 */
@Component
public class JsonGrammar {

    //气象大数据平台秘钥 ==> 只有七天期限 ==> 可免费申请
    private static final String WEATHER_RSA = "7d4e980c9e3c1eaadcd14d1706a82177";

    @Autowired
    RestTemplate restTemplate;

    public ResponseEntity<String> testJson(){
        String url = "http://api.weatherdt.com/common/?area=101010100&type=forecast|observe|rise|calendar|air|history|alarm&key=" + WEATHER_RSA;
        return  restTemplate.getForEntity(url, String.class);
    }

}
